<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
		$sql="select * from `".$oto."_youhui_user_link`,`".$oto."_youhui` where ".$oto."_youhui_user_link.user_id='{$user_id}' and u_is_effect='1' and ".$oto."_youhui_user_link.youhui_id=".$oto."_youhui.id";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$youhui[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($youhui))
		{
			for($i=0;$i<count($youhui);$i++)
			{
				$shopId=$youhui[$i]['supplier_id'];
				$sql="select shopName,shopId,shopImg from `".$oto."_shops` where shopId='{$shopId}'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$shops[$i][]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($shops[$i]))
				{
					$youhui[$i]['shopName']=$shops[$i][0]['shopName'];
					$youhui[$i]['shopId']=$shops[$i][0]['shopId'];
					$youhui[$i]['shopImg']=$shops[$i][0]['shopImg'];
				}
				else
				{
					$youhui[$i]['shopName']="";
					$youhui[$i]['shopId']="";
					$youhui[$i]['shopImg']="";
				}
				if($youhui[$i]['youhui_scope']==1)
				{
					$youhui[$i]['msg']="全部商品";
				}
				if($youhui[$i]['youhui_scope']==2)
				{
					$shop_cat_id=$youhui[$i]['shop_cat_id'];
					$shop_cat_name="";
					$sql="select catName from `".$oto."_shops_cats` where catId='{$shop_cat_id}'";
					$result=$db->query($sql);
					while($row=$result->fetch_assoc()){
						$shop_cat[$i][]=$row;//将取得的所有数据赋值给person_info数组
					}
					if(isset($shop_cat[$i]))
					{
						$shop_cat_name=$shop_cat[$i][0]['catName'];
					}
					$youhui[$i]['msg']="店铺分类：".$shop_cat_name;
				}
				if($youhui[$i]['youhui_scope']==3)
				{
					$goods_id=$youhui[$i]['good_id'];
					$sql="select goodsName from `".$oto."_goods` where goodsId='{$goods_id}'";
					$result=$db->query($sql);
					while($row=$result->fetch_assoc()){
						$goods[$i][]=$row;//将取得的所有数据赋值给person_info数组
					}
					if(isset($goods[$i]))
					{
						$goodsName=$goods[$i][0]['goodsName'];
					}
					else $goodsName="";
					$youhui[$i]['msg']="商品：".$goodsName;
				}
				if($youhui[$i]['youhui_scope']==4)
				{
					$brand_id=$youhui[$i]['brand_id'];
					$brand_name="";
					$sql="select brandName from `".$oto."_brands` where brandId='{$brand_id}'";
					$result=$db->query($sql);
					while($row=$result->fetch_assoc()){
						$brand[$i][]=$row;//将取得的所有数据赋值给person_info数组
					}
					if(isset($brand[$i]))
					{
						$brand_name=$brand[$i][0]['brandName'];
					}
					$youhui[$i]['msg']="品牌：".$brand_name;
				}
				if($youhui[$i]['youhui_scope']==5)
				{
					$cat_name="";
					$cat_id=$youhui[$i]['deal_cate_id'];
					$sql="select catName from `".$oto."_goods_cats` where catId='{$cat_id}'";
					$result=$db->query($sql);
					while($row=$result->fetch_assoc()){
						$cat[$i][]=$row;//将取得的所有数据赋值给person_info数组
					}
					if(isset($cat[$i]))
					{
						$cat_name=$cat[$i][0]['catName'];
					}
					$youhui[$i]['msg']="商城分类：".$cat_name;
				}
			}
		}
		echo json_encode($youhui);
?>